<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>File: README.rdoc</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



  <div id="fileHeader">
    <h1>README.rdoc</h1>
    <table class="header-table">
    <tr class="top-aligned-row">
      <td><strong>Path:</strong></td>
      <td>README.rdoc
      </td>
    </tr>
    <tr class="top-aligned-row">
      <td><strong>Last Update:</strong></td>
      <td>Sun May 01 07:51:31 -0700 2011</td>
    </tr>
    </table>
  </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <h1>INSTALLATION</h1>
<p>
rails plugin install git@github.com:jeroeningen/acts_as_price.git
</p>
<h1>USAGE</h1>
<p>
Create a column in the table of your database which you want to acts as a
price.
</p>
<p>
NOTE THAT THE COLUMN MUST BE OF THE TYPE INTEGER.
</p>
<p>
In your model add the following:
</p>
<ul>
<li>acts_as_price column_name, {:validates =&gt; true, :comma_seperated =&gt;
true, :currency =&gt; currency}

</li>
</ul>
<p>
column_name is the name of your database column e.g. price or
price_per_liter.
</p>
<p>
validates is optional and add validation to the column
</p>
<p>
comma_seperated is optional and return the price comma seperated instead of
dot seperated
</p>
<p>
currency is optional and adds a prefix for the currency to the price.
</p>
<p>
This plugin creates the following getters and setters:
</p>
<ul>
<li>&#8216;price_in_cents&#8217; and &#8217;&lt;column_name&gt;_in_cents&#8217;
sets and returns the price in cents

</li>
<li>&#8216;price&#8217; and &#8217;&lt;column_name&gt;&#8217; sets and returns
the price

</li>
</ul>
<h1>EXAMPLES</h1>
<pre>
 class Car &lt; ActiveRecord::Base
  acts_as_price :price, :comma_seperated =&gt; true, :currency =&gt; &quot;EUR&quot;
 end
</pre>
<p>
car = Car.new :price =&gt; 12999
</p>
<p>
car.price -&gt; EUR. 12999,00
</p>
<p>
car.price_in_cents -&gt; 1299900
</p>
<pre>
 class Fueltype &lt; ActiveRecord::Base
  acts_as_price :price_per_liter, :validates =&gt; true
 end
</pre>
<p>
fuel = Fueltype.new :price_per_liter =&gt; 1.12
</p>
<p>
fuel.price -&gt; 1.12
</p>
<p>
fuel.price_in_cents -&gt; 112
</p>
<p>
fuel.price_per_liter -&gt; 1.12
</p>
<p>
fuel.price_per_liter_in_cents -&gt; 1.12
</p>
<h1>RSPEC INTERGRATION</h1>
<p>
Acts As Price comes with a helper method to automatically test the plugin
using Rspec.
</p>
<p>
To use this method please add the following to your spec_helper.rb file:
</p>
<ul>
<li>config.include(ActsAsPriceHelper)

</li>
<li>and if you using the gem, please also add: require
&#8216;acts_as_price_helper&#8216;

</li>
</ul>
<p>
Now you may add the following code to your spec-files for your models:
</p>
<pre>
  context &quot;given an valid model&quot; do
    it &quot;should acts as price&quot; do
      test_acts_as_price_methods &lt;column_name&gt;, &lt;fixture or stub&gt;
    end
  end
</pre>
<h1>TESTING</h1>
<p>
To test the plugin use the command &#8216;rspec spec/**&#8217; inside the
dir &#8217;~/vendor/plugins/acts_as_price&#8216;
</p>
<h1>KNOWN BUGS</h1>
<p>
The command &#8216;rake test&#8217; is not running properly at the moment.
</p>
<h1>NOTES</h1>
<p>
This plugin comes with Rspec tests. However this plugin assumes that you
have a database configuration, it actually don&#8216;t use the database for
the Rspec tests.
</p>
<h1>FEEDBACK AND BUGS REPORTS</h1>
<p>
For feedback and bug reports contact: jeroeningen@gmail.com
</p>

    </div>


   </div>


  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>